package com.gibs.peixunapi.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.gibs.peixunapi.model.ExamAndTeacher;

@Repository
public interface ExamAndTeacherDao extends JpaRepository<ExamAndTeacher, Integer>, JpaSpecificationExecutor<ExamAndTeacher> {

	@Query("from ExamAndTeacher where teacherId = ?1")
	List<ExamAndTeacher> find(String name);

	@Query("from ExamAndTeacher where teacherId like ?1")
	List<ExamAndTeacher> findLike(String name);

	@Query(value = "select * from ExamAndTeacher limit ?, ?", nativeQuery = true)
	List<ExamAndTeacher> findPage(Integer offset, Integer size);

	@Query(value = "select * from ExamAndTeacher where teacherId = ? limit ?, ?", nativeQuery = true)
	List<ExamAndTeacher> findPage(String name, Integer offset, Integer size);

	@Query(value = "select * from ExamAndTeacher where teacherId like ? limit ?, ?", nativeQuery = true)
	List<ExamAndTeacher> findPageLike(String name, Integer offset, Integer size);

	@Query(value = "select count(*) from ExamAndTeacher where teacherId = ?", nativeQuery = true)
	Long count(String name);

	@Query(value = "select count(*) from ExamAndTeacher where teacherId like ?", nativeQuery = true)
	Long countLike(String name);
	
	@Query("from ExamAndTeacher order by id asc")
	List<ExamAndTeacher> findAllAsc();
}

